package com.zshan.clinic.admin.task;


import com.zshan.clinic.admin.entity.dto.ClinicMedicalDTO;
import com.zshan.clinic.admin.entity.medical.PatientMedicalField;
import com.zshan.clinic.admin.entity.vo.ClinicMedicalDetailVo;
import com.zshan.clinic.admin.service.medical.ClinicMedicalService;
import com.zshan.clinic.admin.service.stat.ClinicIncomeDailyService;
import com.zshan.clinic.database.model.StatClinicIncomeDaily;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 异步线程类
 */
@Service
@Slf4j
public class AsyncTaskService {

    @Autowired
    private ClinicIncomeDailyService clinicIncomeDailyService;

    @Autowired
    @Lazy
    private ClinicMedicalService clinicMedicalService;

    /**
     * 异步保存诊所营收统计
     * @param statClinicIncomeDaily
     */
    @Async("taskExecutor")
    public void asyncSaveOrUpdateClinicIncome(StatClinicIncomeDaily statClinicIncomeDaily){
        clinicIncomeDailyService.saveOrUpdate(statClinicIncomeDaily);
    }

    /**
     * 门诊完成之后的动作
     * @param clinicMedicalDTO
     */
    @Async("taskExecutor")
    public void asyncHandleMedicalCompleted2(PatientMedicalField patientMedicalField,ClinicMedicalDTO clinicMedicalDTO, ClinicMedicalDetailVo clinicMedicalDetailVo){
        clinicMedicalService.handleMedicalCompleted2(patientMedicalField,clinicMedicalDTO,clinicMedicalDetailVo);
    }


    /**
     * 异步发送邮件
     * @param group
     * @param subject
     * @param text
     */
    @Async("taskExecutor")
    public void sendMail(String group,String subject,String text){
    }
}
